<template>
  <view>
    <cu-custom
      bgColor="bg-white"
      :isBack="true"
    >
      <block slot="backText">返回</block>
      <block slot="content">{{title}}</block>
    </cu-custom>
    <div class="topicdetail">
      <div class="content">
        <div
          v-if="topicdetaillength != 0"
          class="detail"
		  v-html = "replace(goods_desc)"
        >
         <!-- <rich-text :nodes="goods_desc" />
          </rich-text> -->
		  <jyf-parser :html="goods_desc" ref="article"></jyf-parser>
		  
        </div>
        <div
          v-else
          style="text-align: center;"
        >该文章一篇空白,什么都没有~~</div>
      </div>
      <!--    <div class="list">-->
      <!--      <p class="title">专题推荐</p>-->
      <!--      <div @click="topicdetail(item.id)" v-for="(item, index) in recommendList" :key="index" class="item">-->
      <!--        <img :src="item.scene_pic_url" alt="">-->
      <!--        <p>{{item.title}}</p>-->
      <!--      </div>-->
      <!--    </div>-->
    </div>
  </view>
</template>

<script>
import { topicdetailListApi } from "@/server/config.js";
import jyfParser from "@/components/jyf-parser/jyf-parser";
export default {
  created() {},
  onLoad(options) {
  	this.id = options.id;
  },
  mounted() {
    this.id = this.id;
    this.getListData();
  },
  data() {
    return {
      recommendList: [],
	  title:"",
      id: "",
      goods_desc: "",
      topicdetaillength: ""
    };
  },
  components: {
	  jyfParser
  },
  methods: {
    topicdetail(id) {
      uni.navigateTo({
        url: "/apiShop/topicdetail/main?id=" + id
      });
    },
    async getListData() {
      const data = await topicdetailListApi({ id: this.id });
      // this.goods_desc = data.data.content;
      this.goods_desc = data.data.content.replace(
        /\<img/gi,
        '<img style="max-width:100%;height:auto;vertical-align: bottom;" '
      );
      this.topicdetaillength = this.goods_desc.length;
      this.recommendList = data.recommendList;
	  this.title = data.data.title || "文章詳細";
    },
	replace:function(demo){
		return demo.replace('<o:p></o:p>','');
	},
  },
  computed: {}
};
</script>
<style lang='scss' scoped>
@import "./style";
</style>
